package com.pds.web.maintenance.controller;

import com.pds.common.core.controller.BaseController;
import com.pds.common.core.domain.R;
import com.pds.common.core.page.TableDataInfo;
import com.pds.web.maintenance.entity.PdsEnvironmentGuidanceStep;
import com.pds.web.maintenance.service.PdsEnvironmentGuidanceStepService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;

/**
 * 规范指导步骤
 *
 * @author srf sunlightcs@gmail.com
 * @since 1.0.0 2024-02-23
 */
@RestController
@RequestMapping("/environmentGuidanceStep")
@Api(tags="规范指导步骤")
public class PdsEnvironmentGuidanceStepController extends BaseController{
    @Resource
    private PdsEnvironmentGuidanceStepService pdsEnvironmentGuidanceStepService;

    /**
     * 分页查询规范指导步骤
     *
     *   pageNum/pageSize分页字段
     *   筛选条件字段
     * @return 查询结果
     */
    @ApiOperation("分页查询规范指导步骤")
    @GetMapping("/page")
    public TableDataInfo pageEnvironmentGuidanceStep(PdsEnvironmentGuidanceStep pdsEnvironmentGuidanceStep){
        startPage();
        List<PdsEnvironmentGuidanceStep> list = pdsEnvironmentGuidanceStepService.selectList(pdsEnvironmentGuidanceStep);
        return getDataTable(list);
    }

    /**
     * 查询规范指导步骤列表
     *
     *   筛选条件字段
     * @return 查询结果
     */
    @ApiOperation("查询规范指导步骤列表")
    @GetMapping("/list")
    public R<List<PdsEnvironmentGuidanceStep>> listEnvironmentGuidanceStep(PdsEnvironmentGuidanceStep pdsEnvironmentGuidanceStep){
        List<PdsEnvironmentGuidanceStep> list = pdsEnvironmentGuidanceStepService.selectList(pdsEnvironmentGuidanceStep);
        return R.ok(list);
    }

    /**
     * 根据ID查询规范指导步骤
     *
     * @param id 主键
     * @return 单条数据
     */
    @ApiOperation("规范指导步骤详情")
    @GetMapping("/queryById/{id}")
    public R<PdsEnvironmentGuidanceStep> queryEnvironmentGuidanceStepById(@PathVariable("id")Long id) {
        return R.ok(pdsEnvironmentGuidanceStepService.queryById(id));
    }

    /**
     * 创建规范指导步骤
     * @param pdsEnvironmentGuidanceStep 记录
     * @return 规范指导步骤
     */
    @ApiOperation("创建规范指导步骤")
    @PostMapping("/add")
    public R<PdsEnvironmentGuidanceStep> addEnvironmentGuidanceStep(@RequestBody PdsEnvironmentGuidanceStep pdsEnvironmentGuidanceStep){
        return R.ok(pdsEnvironmentGuidanceStepService.insert(pdsEnvironmentGuidanceStep));
    }

    /**
     * 修改规范指导步骤
     * @param pdsEnvironmentGuidanceStep 记录
     * @return 成功标识
     */
    @ApiOperation("修改规范指导步骤")
    @PutMapping("/edit")
    public R<Boolean> editEnvironmentGuidanceStep(@RequestBody PdsEnvironmentGuidanceStep pdsEnvironmentGuidanceStep){
        return R.ok(pdsEnvironmentGuidanceStepService.update(pdsEnvironmentGuidanceStep));
    }

    /**
     * 根据ID删除规范指导步骤
     *
     * @param id 主键
     * @return 删除是否成功
     */
    @ApiOperation("删除规范指导步骤")
    @DeleteMapping("/delete")
    public R<Boolean> deleteEnvironmentGuidanceStepById(@RequestParam Long id) {
        return R.ok(pdsEnvironmentGuidanceStepService.deleteById(id));
    }
}